<!DOCTYPE html>
<!-- saved from url=(0046)https://www.cnblogs.com/keithtt/p/8440134.html -->
<html lang="zh-cn"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园</title>
<link type="text/css" rel="stylesheet" href="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/blog-common.css">
<link id="MainCss" type="text/css" rel="stylesheet" href="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/bundle-facebook.css">
<link id="mobile-style" media="only screen and (max-width: 767px)" type="text/css" rel="stylesheet" href="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/bundle-facebook-mobile.css">
<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/keithtt/rss">
<link title="RSD" type="application/rsd+xml" rel="EditURI" href="http://www.cnblogs.com/keithtt/rsd.xml">
<link type="application/wlwmanifest+xml" rel="wlwmanifest" href="http://www.cnblogs.com/keithtt/wlwmanifest.xml">
<script async="" src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/analytics.js.下载"></script><script src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/jquery-2.2.0.min.js.下载"></script>
<script type="text/javascript">var currentBlogApp = 'keithtt', cb_enable_mathjax=false;var isLogined=false;</script>
<script src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/blog-common.js.下载" type="text/javascript"></script>
</head>
<body>
<a name="top"></a>

<div id="home">
<div id="header">
	<div id="blogTitle">
		
<!--done-->
<h1><a id="Header2_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/keithtt/">KeithTt</a></h1>
<h2></h2>



		
	</div><!--end: blogTitle 博客的标题和副标题 -->
	<div id="navigator">
		
<!--done-->
			<ul id="navList">
				<li><a id="blog_nav_sitehome" class="menu" href="http://www.cnblogs.com/">博客园</a></li>
				<li><a id="blog_nav_myhome" class="menu" href="http://www.cnblogs.com/keithtt/">首页</a></li>
				<li><a id="blog_nav_newpost" class="menu" rel="nofollow" href="https://i.cnblogs.com/EditPosts.aspx?opt=1">新随笔</a></li>
				<li><a id="blog_nav_contact" accesskey="9" class="menu" rel="nofollow" href="https://msg.cnblogs.com/send/KeithTt">联系</a></li>
				<li><a id="blog_nav_admin" class="menu" rel="nofollow" href="https://i.cnblogs.com/">管理</a></li>
				<li><a id="blog_nav_rss" class="menu" href="http://www.cnblogs.com/keithtt/rss">订阅</a>
				<a id="blog_nav_rss_image" class="aHeaderXML" href="http://www.cnblogs.com/keithtt/rss"><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/xml.gif" alt="订阅"></a></li>
			</ul>


		<div class="blogStats">
			
			<div id="blog_stats">
<!--done-->
随笔- 133&nbsp;
文章- 0&nbsp;
评论- 10&nbsp;
</div>
			
		</div><!--end: blogStats -->
	</div><!--end: navigator 博客导航栏 -->
</div><!--end: header 头部 -->

<div id="main">
	<div id="mainContent">
	<div class="forFlow">
		
<div id="post_detail">
<!--done-->
<div id="topics">
	<div class="post">
		<h1 class="postTitle">
			<a id="cb_post_title_url" class="postTitle2" href="http://www.cnblogs.com/keithtt/p/8440134.html">jenkins构建docker镜像上传到harbor并发布到kubernetes</a>
		</h1>
		<div class="clear"></div>
		<div class="postBody">
			<div id="cnblogs_post_body" class="blogpost-body cnblogs-markdown"><p>很早之前写过一篇jenkins集成docker的文章，使用的是<strong>CloudBees Docker Build and Publish plugin</strong>插件。这篇文章是直接使用shell脚本做的，主要是这次有一个需求是检测harbor仓库里面是否已经存在要构建的镜像，如果存在就放弃构建，如果不存在则构建镜像并上传到harbor仓库，我这里是通过请求harbor的api来检测的。</p>
<p>整个过程大致分为四个步骤，画了一个简单的图：</p>
<p><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/1005945-20180210234113732-793349406.png"></p>
<p>1、在jenkins上构建一个<em>自由风格的软件项目</em>。</p>
<p>2、源码管理使用git。</p>
<p><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/1005945-20180210234620888-1203386741.png"></p>
<p>这里的账号是gitlab上的账号。</p>
<p>3、构建触发器，我这里使用的是<strong>Poll SCM</strong>定时检测，即每隔一段时间检测一次代码是否有更新。</p>
<p><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/1005945-20180210234850013-773445929.png"></p>
<p>4、添加构建步骤。</p>
<p>这个过程是这样：</p>
<ul>
<li>读取自定义tag，并赋值给一个变量。</li>
<li>检测harbor仓库上是否有该镜像。如果没有则构建镜像并上传到harbor，如果有则退出。</li>
<li>通用ssh发布到kubernetes。</li>
</ul>
<p>需要单独说一下的是，我这里需要使用自定义tag，我使用一个插件<strong>Environment Injector Plugin</strong>将这个变量变成jenkins环境变量，让其能在jenkins上调用。</p>
<p><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/1005945-20180210235917529-1648518399.png"></p>
<p><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/1005945-20180210235952826-225213914.png"></p>
<p><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/1005945-20180211000100341-1049076236.png"></p>
<p>另外，ssh到远程机器上执行命令需要添加授权。系统设置 -&gt; SSH remote hosts</p>
<p><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/1005945-20180211000349763-2145964832.png"></p>
<p>这里的账号是ssh连接的远程主机的用户和私钥（或者账号和密码）。</p>
<p>5、到这里整个过程基本完成了，进入项目，尝试构建。</p>
<p><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/1005945-20180211000908904-1880320375.png"></p>
<p>控制台输出，由于太长我就直接贴文字了：</p>
<pre><code class="hljs haskell"><span class="hljs-type">Started</span> by user shengyongp
[<span class="hljs-type">EnvInject</span>] - <span class="hljs-type">Loading</span> node environment variables.
<span class="hljs-type">Building</span> <span class="hljs-keyword">in</span> workspace /var/lib/tomcat8/.jenkins/workspace/k8sdesktop
 &gt; git rev-parse <span class="hljs-comment">--is-inside-work-tree # timeout=10</span>
<span class="hljs-type">Fetching</span> changes from the remote <span class="hljs-type">Git</span> repository
 &gt; git config remote.origin.url git@git.oupeng.com:sa/k8sdesktop.git # timeout=<span class="hljs-number">10</span>
<span class="hljs-type">Fetching</span> upstream changes from git@git.oupeng.com:sa/k8sdesktop.git
 &gt; git <span class="hljs-comment">--version # timeout=10</span>
<span class="hljs-title">using</span> <span class="hljs-type">GIT_ASKPASS</span> to set credentials 
 &gt; git fetch <span class="hljs-comment">--tags --progress git@git.oupeng.com:sa/k8sdesktop.git +refs/heads/*:refs/remotes/origin/*</span>
 &gt; git rev-parse refs/remotes/origin/master^{commit} # timeout=<span class="hljs-number">10</span>
 &gt; git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=<span class="hljs-number">10</span>
<span class="hljs-type">Checking</span> out <span class="hljs-type">Revision</span> <span class="hljs-number">7593</span>b720066259d291a31a8eb25121c260dd6e00 (refs/remotes/origin/master)
 &gt; git config core.sparsecheckout # timeout=<span class="hljs-number">10</span>
 &gt; git checkout -f <span class="hljs-number">7593</span>b720066259d291a31a8eb25121c260dd6e00
<span class="hljs-type">Commit</span> message: <span class="hljs-string">"update"</span>
 &gt; git rev-list <span class="hljs-comment">--no-walk 7593b720066259d291a31a8eb25121c260dd6e00 # timeout=10</span>
[k8sdesktop] $ /bin/sh -xe /tmp/tomcat8-tomcat8-tmp/jenkins6696265847877639661.sh
+ cat last_tag
+ <span class="hljs-type">LAST_TAG</span>=<span class="hljs-number">0.0</span><span class="hljs-number">.5</span>
+ echo <span class="hljs-type">LAST_TAG</span>=<span class="hljs-number">0.0</span><span class="hljs-number">.5</span>
+ curl -i -s -k https://harbor.oupeng.com/api/repositories/k8sdesktop%<span class="hljs-number">2</span>Fk8sdesktop/tags/<span class="hljs-number">0.0</span><span class="hljs-number">.5</span>
+ awk {print $<span class="hljs-number">2</span>}
+ head <span class="hljs-number">-1</span>
+ is_exsist=<span class="hljs-number">404</span>
+ [ <span class="hljs-number">404</span> -ne <span class="hljs-number">200</span> ]
+ echo <span class="hljs-type">Image</span> not exsist, prepare to build it.
<span class="hljs-type">Image</span> not exsist, prepare to build it.
+ docker build -t harbor.oupeng.com/k8sdesktop/k8sdesktop:<span class="hljs-number">0.0</span><span class="hljs-number">.5</span> .
<span class="hljs-type">Sending</span> build context to <span class="hljs-type">Docker</span> daemon  <span class="hljs-number">60.25</span>MB

<span class="hljs-type">Step</span> <span class="hljs-number">1</span>/<span class="hljs-number">10</span> : <span class="hljs-type">FROM</span> alpine:<span class="hljs-number">3.7</span>
 <span class="hljs-comment">---&gt; 3fd9065eaf02</span>
<span class="hljs-type">Step</span> <span class="hljs-number">2</span>/<span class="hljs-number">10</span> : <span class="hljs-type">MAINTAINER</span> <span class="hljs-string">"weiduan"</span>
 <span class="hljs-comment">---&gt; Using cache</span>
 <span class="hljs-comment">---&gt; d7053b014ba5</span>
<span class="hljs-type">Step</span> <span class="hljs-number">3</span>/<span class="hljs-number">10</span> : <span class="hljs-type">RUN</span> rm /etc/apk/repositories
 <span class="hljs-comment">---&gt; Using cache</span>
 <span class="hljs-comment">---&gt; a73bff2a847a</span>
<span class="hljs-type">Step</span> <span class="hljs-number">4</span>/<span class="hljs-number">10</span> : <span class="hljs-type">ADD</span> /sources/repositories /etc/apk/repositories
 <span class="hljs-comment">---&gt; Using cache</span>
 <span class="hljs-comment">---&gt; dfbb18dfbfbd</span>
<span class="hljs-type">Step</span> <span class="hljs-number">5</span>/<span class="hljs-number">10</span> : <span class="hljs-type">RUN</span> apk add <span class="hljs-comment">--no-cache python3 supervisor nginx python3-dev build-base linux-headers pcre-dev openldap-dev     &amp;&amp; pip3 install --no-cache-dir uwsgi django django-auth-ldap PyMySQL</span>
 <span class="hljs-comment">---&gt; Using cache</span>
 <span class="hljs-comment">---&gt; 9b318af7da67</span>
<span class="hljs-type">Step</span> <span class="hljs-number">6</span>/<span class="hljs-number">10</span> : <span class="hljs-type">ADD</span> sources/ /<span class="hljs-class"><span class="hljs-keyword">data</span></span>
 <span class="hljs-comment">---&gt; Using cache</span>
 <span class="hljs-comment">---&gt; 600dcbcc0935</span>
<span class="hljs-type">Step</span> <span class="hljs-number">7</span>/<span class="hljs-number">10</span> : <span class="hljs-type">WORKDIR</span> /<span class="hljs-class"><span class="hljs-keyword">data</span></span>
 <span class="hljs-comment">---&gt; Using cache</span>
 <span class="hljs-comment">---&gt; 4b4b2687ac2f</span>
<span class="hljs-type">Step</span> <span class="hljs-number">8</span>/<span class="hljs-number">10</span> : <span class="hljs-type">RUN</span> ln -s /usr/lib/python3<span class="hljs-number">.6</span>/site-packages/django/contrib/admin/static/admin /<span class="hljs-class"><span class="hljs-keyword">data</span>/k8sdesktop/static/     &amp;&amp; rm -f /etc/nginx/nginx.conf /etc/supervisord.conf /usr/bin/python     &amp;&amp; mkdir -p /etc/nginx/sites-enabled /var/log/uwsgi /run/nginx     &amp;&amp; ln -s /usr/bin/python3 /usr/bin/python     &amp;&amp; ln -s /<span class="hljs-keyword">data</span>/supervisord.conf /etc/     &amp;&amp; ln -s /<span class="hljs-keyword">data</span>/nginx.conf /etc/nginx/     &amp;&amp; ln -s /<span class="hljs-keyword">data</span>/k8sdesktop.conf /etc/nginx/sites-enabled/</span>
 <span class="hljs-comment">---&gt; Using cache</span>
 <span class="hljs-comment">---&gt; 4f3f962c0635</span>
<span class="hljs-type">Step</span> <span class="hljs-number">9</span>/<span class="hljs-number">10</span> : <span class="hljs-type">EXPOSE</span> <span class="hljs-number">80</span>
 <span class="hljs-comment">---&gt; Using cache</span>
 <span class="hljs-comment">---&gt; 2604a91e376d</span>
<span class="hljs-type">Step</span> <span class="hljs-number">10</span>/<span class="hljs-number">10</span> : <span class="hljs-type">ENTRYPOINT</span> [<span class="hljs-string">"supervisord"</span>, <span class="hljs-string">"-n"</span>]
 <span class="hljs-comment">---&gt; Using cache</span>
 <span class="hljs-comment">---&gt; dde892e6136a</span>
<span class="hljs-type">Successfully</span> built dde892e6136a
<span class="hljs-type">Successfully</span> tagged harbor.oupeng.com/k8sdesktop/k8sdesktop:<span class="hljs-number">0.0</span><span class="hljs-number">.5</span>
+ echo <span class="hljs-type">Push</span> the image to <span class="hljs-type">Harbor</span>.
<span class="hljs-type">Push</span> the image to <span class="hljs-type">Harbor</span>.
+ docker push harbor.oupeng.com/k8sdesktop/k8sdesktop:<span class="hljs-number">0.0</span><span class="hljs-number">.5</span>
<span class="hljs-type">The</span> push refers to repository [harbor.oupeng.com/k8sdesktop/k8sdesktop]
<span class="hljs-number">950915917e6</span>f: <span class="hljs-type">Preparing</span>
<span class="hljs-number">7</span>d26b9ed8228: <span class="hljs-type">Preparing</span>
<span class="hljs-number">82</span>a138967623: <span class="hljs-type">Preparing</span>
<span class="hljs-title">ba67b311ae84</span>: <span class="hljs-type">Preparing</span>
<span class="hljs-number">68</span>b0d545b5ec: <span class="hljs-type">Preparing</span>
<span class="hljs-title">cd7100a72410</span>: <span class="hljs-type">Preparing</span>
<span class="hljs-title">cd7100a72410</span>: <span class="hljs-type">Waiting</span>
<span class="hljs-number">68</span>b0d545b5ec: <span class="hljs-type">Layer</span> already exists
<span class="hljs-title">cd7100a72410</span>: <span class="hljs-type">Layer</span> already exists
<span class="hljs-number">950915917e6</span>f: <span class="hljs-type">Pushed</span>
<span class="hljs-title">ba67b311ae84</span>: <span class="hljs-type">Pushed</span>
<span class="hljs-number">7</span>d26b9ed8228: <span class="hljs-type">Pushed</span>
<span class="hljs-number">82</span>a138967623: <span class="hljs-type">Pushed</span>
<span class="hljs-number">0.0</span><span class="hljs-number">.5</span>: digest: sha256:<span class="hljs-number">43</span>efbc46adef6eb7644ebaa7fe2c46dd91cfc6be9926457f276fc001e2c6543e size: <span class="hljs-number">1574</span>
[<span class="hljs-type">EnvInject</span>] - <span class="hljs-type">Injecting</span> environment variables from a build step.
[<span class="hljs-type">EnvInject</span>] - <span class="hljs-type">Injecting</span> <span class="hljs-keyword">as</span> environment variables the properties file path 'tmp.tags'
[<span class="hljs-type">EnvInject</span>] - <span class="hljs-type">Variables</span> injected successfully.
[<span class="hljs-type">SSH</span>] script:
<span class="hljs-type">LAST_TAG</span>=<span class="hljs-string">"0.0.5"</span>

<span class="hljs-title">sed</span> -ri <span class="hljs-string">"s@(image\:.*\:).*@\1${LAST_TAG}@"</span> /root/k8sdesktop.yaml

<span class="hljs-title">kubectl</span> apply -f /root/k8sdesktop.yaml

[<span class="hljs-type">SSH</span>] executing...
<span class="hljs-title">deployment</span> <span class="hljs-string">"k8sdesktop-deployment"</span> unchanged
<span class="hljs-title">service</span> <span class="hljs-string">"k8sdesktop-deployment"</span> unchanged

[<span class="hljs-type">SSH</span>] completed
[<span class="hljs-type">SSH</span>] exit-status: <span class="hljs-number">0</span>

[k8sdesktop] $ /bin/sh -xe /tmp/tomcat8-tomcat8-tmp/jenkins7903574837135018812.sh
+ rm -f tmp.tags
<span class="hljs-type">Finished</span>: <span class="hljs-type">SUCCESS</span></code></pre>
</div><div id="MySignature"></div>
<div class="clear"></div>
<div id="blog_post_info_block">
<div id="BlogPostCategory"></div>
<div id="EntryTag">标签: <a href="http://www.cnblogs.com/keithtt/tag/jenkins/">jenkins</a>, <a href="http://www.cnblogs.com/keithtt/tag/kubernetes/">kubernetes</a></div>
<div id="blog_post_info"><div id="green_channel">
        <a href="javascript:void(0);" id="green_channel_digg" onclick="DiggIt(8440134,cb_blogId,1);green_channel_success(this,&#39;谢谢推荐！&#39;);">好文要顶</a>
            <a id="green_channel_follow" onclick="follow(&#39;d458a197-785d-e611-9fc1-ac853d9f53cc&#39;);" href="javascript:void(0);">关注我</a>
    <a id="green_channel_favorite" onclick="AddToWz(cb_entryId);return false;" href="javascript:void(0);">收藏该文</a>
    <a id="green_channel_weibo" href="javascript:void(0);" title="分享至新浪微博" onclick="ShareToTsina()"><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/icon_weibo_24.png" alt=""></a>
    <a id="green_channel_wechat" href="javascript:void(0);" title="分享至微信" onclick="shareOnWechat()"><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/wechat.png" alt=""></a>
</div>
<div id="author_profile">
    <div id="author_profile_info" class="author_profile_info">
            <a href="http://home.cnblogs.com/u/keithtt/" target="_blank"><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/20170226111822.png" class="author_avatar" alt=""></a>
        <div id="author_profile_detail" class="author_profile_info">
            <a href="http://home.cnblogs.com/u/keithtt/">KeithTt</a><br>
            <a href="http://home.cnblogs.com/u/keithtt/followees">关注 - 5</a><br>
            <a href="http://home.cnblogs.com/u/keithtt/followers">粉丝 - 9</a>
        </div>
    </div>
    <div class="clear"></div>
    <div id="author_profile_honor"></div>
    <div id="author_profile_follow">
                <a href="javascript:void(0);" onclick="follow(&#39;d458a197-785d-e611-9fc1-ac853d9f53cc&#39;);return false;">+加关注</a>
    </div>
</div>
<div id="div_digg">
    <div class="diggit" onclick="votePost(8440134,&#39;Digg&#39;)">
        <span class="diggnum" id="digg_count">0</span>
    </div>
    <div class="buryit" onclick="votePost(8440134,&#39;Bury&#39;)">
        <span class="burynum" id="bury_count">0</span>
    </div>
    <div class="clear"></div>
    <div class="diggword" id="digg_tips">
    </div>
</div>
<script type="text/javascript">
    currentDiggType = 0;
</script></div>
<div class="clear"></div>
<div id="post_next_prev"><a href="http://www.cnblogs.com/keithtt/p/8438649.html" class="p_n_p_prefix">« </a> 上一篇：<a href="http://www.cnblogs.com/keithtt/p/8438649.html" title="发布于2018-02-10 14:05">debian9部署jenkins</a><br><a href="http://www.cnblogs.com/keithtt/p/8452058.html" class="p_n_p_prefix">» </a> 下一篇：<a href="http://www.cnblogs.com/keithtt/p/8452058.html" title="发布于2018-02-17 18:27">debian9部署ownCloud</a><br></div>
</div>


		</div>
		<div class="postDesc">posted @ <span id="post-date">2018-02-11 00:12</span> <a href="http://www.cnblogs.com/keithtt/">KeithTt</a> 阅读(<span id="post_view_count">330</span>) 评论(<span id="post_comment_count">0</span>)  <a href="https://i.cnblogs.com/EditPosts.aspx?postid=8440134" rel="nofollow">编辑</a> <a href="https://www.cnblogs.com/keithtt/p/8440134.html#" onclick="AddToWz(8440134);return false;">收藏</a></div>
	</div>
	<script src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/highlight.min.js.下载"></script><script>markdown_highlight();</script><script type="text/javascript">var allowComments=true,cb_blogId=298672,cb_entryId=8440134,cb_blogApp=currentBlogApp,cb_blogUserGuid='d458a197-785d-e611-9fc1-ac853d9f53cc',cb_entryCreatedDate='2018/2/11 0:12:00';loadViewCount(cb_entryId);var cb_postType=1;</script>
	
</div>
<!--end: topics 文章、评论容器-->
</div><a name="!comments"></a><div id="blog-comments-placeholder"></div><script type="text/javascript">var commentManager = new blogCommentManager();commentManager.renderComments(0);</script>
<div id="comment_form" class="commentform">
<a name="commentform"></a>
<div id="divCommentShow"></div>
<div id="comment_nav"><span id="span_refresh_tips"></span><a href="javascript:void(0);" onclick="return RefreshCommentList();" id="lnk_RefreshComments" runat="server" clientidmode="Static">刷新评论</a><a href="https://www.cnblogs.com/keithtt/p/8440134.html#" onclick="return RefreshPage();">刷新页面</a><a href="https://www.cnblogs.com/keithtt/p/8440134.html#top">返回顶部</a></div>
<div id="comment_form_container"><div class="login_tips">注册用户登录后才能发表评论，请 <a rel="nofollow" href="javascript:void(0);" class="underline" onclick="return login(&#39;commentform&#39;);">登录</a> 或 <a rel="nofollow" href="javascript:void(0);" class="underline" onclick="return register();">注册</a>，<a href="http://www.cnblogs.com/">访问</a>网站首页。</div></div>
<div class="ad_text_commentbox" id="ad_text_under_commentbox"></div>
<div id="ad_t2"><a href="http://www.ucancode.com/index.htm" target="_blank">【推荐】超50万VC++源码: 大型组态工控、电力仿真CAD与GIS源码库！</a><br><a href="https://www.cnblogs.com/cmt/p/8525042.html" target="_blank">【活动】2050 大会 - 博客园程序员团聚 （5.25 杭州·云栖小镇）</a><br><a href="http://clickc.admaster.com.cn/c/a105960,b2436452,c1705,i0,m101,8a1,8b2,h" target="_blank">【推荐】0元免费体验华为云服务</a><br><a href="https://cloud.tencent.com/developer/support-plan?fromSource=gwzcw.914464.914464.914464" target="_blank">【活动】腾讯云招募自媒体，共享百万资源包</a><br></div>
<div id="opt_under_post"></div>
<div id="cnblogs_c1" class="c_ad_block"><a onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;C1&#39;);" href="https://cloud.tencent.com/act/free?fromSource=gwzcw.914466.914466.914466" target="_blank"><img width="300" height="250" src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/24442-20180423213639985-818425333.jpg" alt="腾讯云0423"></a></div>
<div id="under_post_news"><div class="itnews c_ad_block"><b>最新IT新闻</b>:<br> ·  <a href="https://news.cnblogs.com/n/595607/" target="_blank">苹果高管解读财报：对中国市场机会和环境非常乐观</a><br> ·  <a href="https://news.cnblogs.com/n/595632/" target="_blank">Google I/O 2018会议曝光 将带来哪些新东西</a><br> ·  <a href="https://news.cnblogs.com/n/595612/" target="_blank">3亿买地建航空总部 圆通追赶“失去的一年”</a><br> ·  <a href="https://news.cnblogs.com/n/595614/" target="_blank">2018年5月全球数据库排名：PostgreSQL 有所回升</a><br> ·  <a href="https://news.cnblogs.com/n/595626/" target="_blank">Facebook推出新款“商业分析”app</a><br>» <a href="http://news.cnblogs.com/" title="IT新闻" target="_blank">更多新闻...</a></div></div>
<div id="cnblogs_c2" class="c_ad_block"><a href="http://click.aliyun.com/m/26880/" target="_blank"><img src="./jenkins构建docker镜像上传到harbor并发布到kubernetes - KeithTt - 博客园_files/TB1WDRaXMoQMeJjy0FnXXb8gFXa-468-60.jpg" alt="" style="width: 468px; height: 60px;"></a></div>
<div id="under_post_kb"><div class="itnews c_ad_block" id="kb_block"><b>最新知识库文章</b>:<br><div id="kb_recent"> ·  <a href="http://kb.cnblogs.com/page/593985/" target="_blank">如何识别人的技术能力和水平？</a><br> ·  <a href="http://kb.cnblogs.com/page/575255/" target="_blank">写给自学者的入门指南</a><br> ·  <a href="http://kb.cnblogs.com/page/578690/" target="_blank">和程序员谈恋爱</a><br> ·  <a href="http://kb.cnblogs.com/page/585734/" target="_blank">学会学习</a><br> ·  <a href="http://kb.cnblogs.com/page/588938/" target="_blank">优秀技术人的管理陷阱</a><br></div>» <a href="http://kb.cnblogs.com/" target="_blank">更多知识库文章...</a></div></div>
<div id="HistoryToday" class="c_ad_block"></div>
<script type="text/javascript">
    fixPostBody();
    setTimeout(function () { incrementViewCount(cb_entryId); }, 50);
    deliverAdT2();
    deliverAdC1();
    deliverAdC2();    
    loadNewsAndKb();
    loadBlogSignature();
    LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
    GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate, cb_postType);
    loadOptUnderPost();
    GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);   
</script>
</div>


	</div><!--end: forFlow -->
	</div><!--end: mainContent 主体内容容器-->

	<div id="sideBar">
		<div id="sideBarMain">
		<div id="calendar"><div id="blog-calendar" style=""><table id="blogCalendar" class="Cal" cellspacing="0" cellpadding="0" title="Calendar">
	<tbody><tr><td colspan="7"><table class="CalTitle" cellspacing="0">
		<tbody><tr><td class="CalNextPrev"><a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2018/04/01&#39;);return false;">&lt;</a></td><td align="center">2018年5月</td><td class="CalNextPrev" align="right"><a href="javascript:void(0);" onclick="loadBlogCalendar(&#39;2018/06/01&#39;);return false;">&gt;</a></td></tr>
	</tbody></table></td></tr><tr><th class="CalDayHeader" align="center" abbr="日" scope="col">日</th><th class="CalDayHeader" align="center" abbr="一" scope="col">一</th><th class="CalDayHeader" align="center" abbr="二" scope="col">二</th><th class="CalDayHeader" align="center" abbr="三" scope="col">三</th><th class="CalDayHeader" align="center" abbr="四" scope="col">四</th><th class="CalDayHeader" align="center" abbr="五" scope="col">五</th><th class="CalDayHeader" align="center" abbr="六" scope="col">六</th></tr><tr><td class="CalOtherMonthDay" align="center">29</td><td class="CalOtherMonthDay" align="center">30</td><td align="center">1</td><td class="CalTodayDay" align="center">2</td><td align="center">3</td><td align="center">4</td><td class="CalWeekendDay" align="center">5</td></tr><tr><td class="CalWeekendDay" align="center">6</td><td align="center">7</td><td align="center">8</td><td align="center">9</td><td align="center">10</td><td align="center">11</td><td class="CalWeekendDay" align="center">12</td></tr><tr><td class="CalWeekendDay" align="center">13</td><td align="center">14</td><td align="center">15</td><td align="center">16</td><td align="center">17</td><td align="center">18</td><td class="CalWeekendDay" align="center">19</td></tr><tr><td class="CalWeekendDay" align="center">20</td><td align="center">21</td><td align="center">22</td><td align="center">23</td><td align="center">24</td><td align="center">25</td><td class="CalWeekendDay" align="center">26</td></tr><tr><td class="CalWeekendDay" align="center">27</td><td align="center">28</td><td align="center">29</td><td align="center">30</td><td align="center">31</td><td class="CalOtherMonthDay" align="center">1</td><td class="CalOtherMonthDay" align="center">2</td></tr><tr><td class="CalOtherMonthDay" align="center">3</td><td class="CalOtherMonthDay" align="center">4</td><td class="CalOtherMonthDay" align="center">5</td><td class="CalOtherMonthDay" align="center">6</td><td class="CalOtherMonthDay" align="center">7</td><td class="CalOtherMonthDay" align="center">8</td><td class="CalOtherMonthDay" align="center">9</td></tr>
</tbody></table></div><script type="text/javascript">loadBlogDefaultCalendar();</script></div>
			
<!--done-->
<div class="newsItem">
<h3 class="catListTitle">公告</h3>
	<div id="blog-news"><div id="profile_block">昵称：<a href="https://home.cnblogs.com/u/keithtt/">KeithTt</a><br>园龄：<a href="https://home.cnblogs.com/u/keithtt/" title="入园时间：2016-08-08">1年8个月</a><br>粉丝：<a href="https://home.cnblogs.com/u/keithtt/followers/">9</a><br>关注：<a href="https://home.cnblogs.com/u/keithtt/followees/">5</a><div id="p_b_follow"><a href="javascript:void(0);" onclick="follow(&#39;d458a197-785d-e611-9fc1-ac853d9f53cc&#39;)">+加关注</a></div><script>getFollowStatus('d458a197-785d-e611-9fc1-ac853d9f53cc')</script></div></div><script type="text/javascript">loadBlogNews();</script>
</div>
			
			
			<div id="leftcontentcontainer">
				<div id="blog-sidecolumn"><div id="sidebar_search" class="sidebar-block">
<div id="sidebar_search" class="mySearch">
<h3 class="catListTitle">搜索</h3>
<div id="sidebar_search_box">
<div id="widget_my_zzk" class="div_my_zzk"><input type="text" id="q" onkeydown="return zzk_go_enter(event);" class="input_my_zzk">&nbsp;<input onclick="zzk_go()" type="button" value="找找看" id="btnZzk" class="btn_my_zzk"></div>
<div id="widget_my_google" class="div_my_zzk"><input type="text" name="google_q" id="google_q" onkeydown="return google_go_enter(event)" class="input_my_zzk">&nbsp;<input onclick="google_go()" type="button" value="谷歌搜索" class="btn_my_zzk"></div>
</div>
</div>

</div><div id="sidebar_shortcut" class="sidebar-block">
<div class="catListLink">
<h3 class="catListTitle">常用链接</h3>
<ul>
<li><a href="http://www.cnblogs.com/keithtt/p/" title="我的博客的随笔列表">我的随笔</a></li><li><a href="http://www.cnblogs.com/keithtt/MyComments.html" title="我发表过的评论列表">我的评论</a></li><li><a href="http://www.cnblogs.com/keithtt/OtherPosts.html" title="我评论过的随笔列表">我的参与</a></li><li><a href="http://www.cnblogs.com/keithtt/RecentComments.html" title="我的博客的评论列表">最新评论</a></li><li><a href="http://www.cnblogs.com/keithtt/tag/" title="我的博客的标签列表">我的标签</a></li>
<li><a id="itemListLink" onclick="this.blur();WarpClass(&#39;itemListLink&#39;, &#39;itemListLin_con&#39;);return false;" href="https://www.cnblogs.com/keithtt/p/8440134.html#">更多链接</a></li>
</ul>
<div id="itemListLin_con" style="display:none;">
<ul>

</ul>
</div>
</div></div><div id="sidebar_toptags" class="sidebar-block">
<div class="catListTag">
<h3 class="catListTitle">我的标签</h3>
<ul>
<li><a href="http://www.cnblogs.com/keithtt/tag/python/">python</a>(23)</li><li><a href="http://www.cnblogs.com/keithtt/tag/docker/">docker</a>(14)</li><li><a href="http://www.cnblogs.com/keithtt/tag/elk/">elk</a>(11)</li><li><a href="http://www.cnblogs.com/keithtt/tag/kubernetes/">kubernetes</a>(11)</li><li><a href="http://www.cnblogs.com/keithtt/tag/lvs/">lvs</a>(6)</li><li><a href="http://www.cnblogs.com/keithtt/tag/mysql/">mysql</a>(6)</li><li><a href="http://www.cnblogs.com/keithtt/tag/debian/">debian</a>(6)</li><li><a href="http://www.cnblogs.com/keithtt/tag/redis/">redis</a>(5)</li><li><a href="http://www.cnblogs.com/keithtt/tag/nginx/">nginx</a>(5)</li><li><a href="http://www.cnblogs.com/keithtt/tag/zabbix/">zabbix</a>(5)</li><li><a href="http://www.cnblogs.com/keithtt/tag/">更多</a></li>
</ul>
</div></div><div id="sidebar_categories">
<div class="catListPostArchive">
<h3 class="catListTitle">随笔档案</h3>

<ul>

<li><a id="CatList_LinkList_0_Link_0" href="http://www.cnblogs.com/keithtt/archive/2018/03.html">2018年3月 (6)</a> </li>

<li><a id="CatList_LinkList_0_Link_1" href="http://www.cnblogs.com/keithtt/archive/2018/02.html">2018年2月 (5)</a> </li>

<li><a id="CatList_LinkList_0_Link_2" href="http://www.cnblogs.com/keithtt/archive/2018/01.html">2018年1月 (5)</a> </li>

<li><a id="CatList_LinkList_0_Link_3" href="http://www.cnblogs.com/keithtt/archive/2017/12.html">2017年12月 (2)</a> </li>

<li><a id="CatList_LinkList_0_Link_4" href="http://www.cnblogs.com/keithtt/archive/2017/11.html">2017年11月 (2)</a> </li>

<li><a id="CatList_LinkList_0_Link_5" href="http://www.cnblogs.com/keithtt/archive/2017/10.html">2017年10月 (20)</a> </li>

<li><a id="CatList_LinkList_0_Link_6" href="http://www.cnblogs.com/keithtt/archive/2017/09.html">2017年9月 (16)</a> </li>

<li><a id="CatList_LinkList_0_Link_7" href="http://www.cnblogs.com/keithtt/archive/2017/08.html">2017年8月 (11)</a> </li>

<li><a id="CatList_LinkList_0_Link_8" href="http://www.cnblogs.com/keithtt/archive/2017/07.html">2017年7月 (10)</a> </li>

<li><a id="CatList_LinkList_0_Link_9" href="http://www.cnblogs.com/keithtt/archive/2017/06.html">2017年6月 (14)</a> </li>

<li><a id="CatList_LinkList_0_Link_10" href="http://www.cnblogs.com/keithtt/archive/2017/05.html">2017年5月 (14)</a> </li>

<li><a id="CatList_LinkList_0_Link_11" href="http://www.cnblogs.com/keithtt/archive/2017/04.html">2017年4月 (8)</a> </li>

<li><a id="CatList_LinkList_0_Link_12" href="http://www.cnblogs.com/keithtt/archive/2017/03.html">2017年3月 (14)</a> </li>

<li><a id="CatList_LinkList_0_Link_13" href="http://www.cnblogs.com/keithtt/archive/2017/02.html">2017年2月 (6)</a> </li>

</ul>

</div>

</div><div id="sidebar_recentcomments" class="sidebar-block"><div id="recent_comments_wrap">
<div class="catListComment">
<h3 class="catListTitle">最新评论</h3>

	<div id="RecentCommentsBlock"><ul>
        <li class="recent_comment_title"><a href="http://www.cnblogs.com/keithtt/p/8136289.html#3915982">1. Re:部署kubernetes1.8.4+contiv高可用集群</a></li>
        <li class="recent_comment_body">@KeithTt不，是出不去外网，我ping不通8.8.8.8，我换个版本试试看。请问你是在单网卡的环境下操作的吗...</li>
        <li class="recent_comment_author">--Sarshes_J</li>
        <li class="recent_comment_title"><a href="http://www.cnblogs.com/keithtt/p/8136289.html#3915514">2. Re:部署kubernetes1.8.4+contiv高可用集群</a></li>
        <li class="recent_comment_body">@Sarshes_J这个多半是dns问题，pod的dns默认是继承宿主机的dns。设置方法参考官网。...</li>
        <li class="recent_comment_author">--KeithTt</li>
        <li class="recent_comment_title"><a href="http://www.cnblogs.com/keithtt/p/8136289.html#3915442">3. Re:部署kubernetes1.8.4+contiv高可用集群</a></li>
        <li class="recent_comment_body">你好，请问你的环境里，从host连pod，以及从pod访问外网都正常吗？我用1.9.4+contiv搭的环境中无法从host访问除了default租户外其他租户网络内的pod，而且所有的pod都无法访......</li>
        <li class="recent_comment_author">--Sarshes_J</li>
        <li class="recent_comment_title"><a href="http://www.cnblogs.com/keithtt/p/6649995.html#3862981">4. Re:一键部署Kubernetes高可用集群</a></li>
        <li class="recent_comment_body">楼主你好，看了你的脚本，未发现部署etcd的内容呢？<br>是用的deploy-etcd.sh吗？</li>
        <li class="recent_comment_author">--粽子仙森</li>
        <li class="recent_comment_title"><a href="http://www.cnblogs.com/keithtt/p/6593866.html#3744794">5. Re:使用nginx代理kibana并设置身份验证</a></li>
        <li class="recent_comment_body">@邓某某iinclude要加在http配置段...</li>
        <li class="recent_comment_author">--KeithTt</li>
</ul>
</div>
</div>
</div></div><div id="sidebar_topviewedposts" class="sidebar-block"><div id="topview_posts_wrap">
<div class="catListView">
<h3 class="catListTitle">阅读排行榜</h3>
	<div id="TopViewPostsBlock"><ul><li><a href="http://www.cnblogs.com/keithtt/p/6410249.html">1. Kubernetes日志收集(5940)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6649995.html">2. 一键部署Kubernetes高可用集群(4279)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6528016.html">3. Zkui安装(3214)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6922378.html">4. Mariadb修改root密码(2668)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/7896948.html">5. 部署kubernetes1.8.3高可用集群(2386)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6593866.html">6. 使用nginx代理kibana并设置身份验证(2329)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6410229.html">7. Jenkins集成Docker(2303)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6410288.html">8. cephfs创建及挂载(2176)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/7089792.html">9. ELK5.4安装Xpack(2172)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6528401.html">10. CentOS下查看nginx和php的编译参数(2046)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6410302.html">11. Kubernetes使用cephfs作为后端存储(1978)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/7591097.html">12. 在docker宿主机上查找指定容器内运行的所有进程的PID(1653)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/7189489.html">13. logstash5生成init脚本后台启动(1363)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/7143970.html">14. debian安装filebeat5.5收集nginx日志(1253)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6919417.html">15. Mac上安装python3并设置SublimeREPL插件默认运行python3(1232)</a></li></ul></div>
</div>
</div></div><div id="sidebar_topcommentedposts" class="sidebar-block"><div id="topfeedback_posts_wrap">
<div class="catListFeedback">
<h3 class="catListTitle">评论排行榜</h3>
	<div id="TopFeedbackPostsBlock"><ul><li><a href="http://www.cnblogs.com/keithtt/p/6649995.html">1. 一键部署Kubernetes高可用集群(4)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/8136289.html">2. 部署kubernetes1.8.4+contiv高可用集群(3)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6593866.html">3. 使用nginx代理kibana并设置身份验证(2)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6528016.html">4. Zkui安装(1)</a></li></ul></div>
</div>
</div></div><div id="sidebar_topdiggedposts" class="sidebar-block"><div id="topdigg_posts_wrap">
<div class="catListView">
<h3 class="catListTitle">推荐排行榜</h3>
<div id="TopDiggPostsBlock"><ul><li><a href="http://www.cnblogs.com/keithtt/p/6410229.html">1. Jenkins集成Docker(1)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6410249.html">2. Kubernetes日志收集(1)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6649995.html">3. 一键部署Kubernetes高可用集群(1)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6649951.html">4. 一键部署ETCD集群脚本(1)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6919417.html">5. Mac上安装python3并设置SublimeREPL插件默认运行python3(1)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/6918062.html">6. MacBook设置终端颜色,补全忽略大小写,设置命令别名alias,设置vim,设置显示git分支(1)</a></li><li><a href="http://www.cnblogs.com/keithtt/p/7410874.html">7. 使用apt-mirror搭建debian本地仓库(1)</a></li></ul></div>
</div></div></div></div><script type="text/javascript">loadBlogSideColumn();</script>
			</div>
			
		</div><!--end: sideBarMain -->
	</div><!--end: sideBar 侧边栏容器 -->
	<div class="clear"></div>
	</div><!--end: main -->
	<div class="clear"></div>
	<div id="footer">
		
<!--done-->
Copyright ©2018 KeithTt
	</div><!--end: footer -->
</div><!--end: home 自定义的最大容器 -->


</body></html>